package org.phantom.demo.search;

import javax.annotation.Resource;

import org.phantom.demo.search.queuetest.Data1;
import org.phantom.demo.search.queuetest.Data2;
import org.phantom.demo.search.queuetest.Data3;
import org.phantom.demo.search.queuetest.DataLevel;
import org.phantom.demo.search.queuetest.TaskQueue;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("task")
public class TaskTestController {

	@Resource
	private TaskQueue<DataLevel> taskQueue = null;
	
	@RequestMapping("level3")
	public ResponseEntity<String> level3(){
		taskQueue.pushTask(new Data3());
		return new ResponseEntity<String>("OK",HttpStatus.OK);
	}
	@RequestMapping("level1and3")
	public ResponseEntity<String> level1AndLevel3(){
		taskQueue.pushTask(new DataLevel[]{new Data1(),new Data3()});
		return new ResponseEntity<String>("OK",HttpStatus.OK);
	}
	@RequestMapping("more")
	public ResponseEntity<String> more(){
		taskQueue.pushTask(new DataLevel[]{new Data1(),new Data3(),new Data3(),new Data2(),new Data2()});
		return new ResponseEntity<String>("OK",HttpStatus.OK);
	}
	
}
